package com.sun.service.controller;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.event.AnalysisEventListener;
import com.sun.common.core.excel.listener.AnalysisValidReadListener;
import com.sun.common.core.model.dto.SimpleVO;
import com.sun.common.core.model.dto.UserExcel;
import com.sun.common.core.utils.ExcelUtil;
import com.sun.service.dto.UlocInfo;
import com.sun.service.entity.UserDo;
import com.sun.service.service.UserService;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.io.Serializable;
import java.net.URLEncoder;
import java.util.*;
import java.util.stream.Collectors;


@RestController
public class ExcelController {

    @Resource
    UserService userService;

    @PostMapping(value = "/import", produces = {MediaType.APPLICATION_JSON_VALUE})
    public SimpleVO importUdtWpcAlmAddProcessParametersDetail(@RequestParam("file") MultipartFile file) throws IOException {
        SimpleVO simpleVO = new SimpleVO();
        AnalysisEventListener<UserExcel> listener = new AnalysisValidReadListener<>(
                userService::checkRow,
                userService::saveAll,
                ExcelUtil.VALIDATOR,
                simpleVO);
        ExcelUtil.readExcel(file.getInputStream(), UserExcel.class, listener);
        return simpleVO;
    }


    @GetMapping(value = "/uloc", produces = {MediaType.APPLICATION_JSON_VALUE})
    public void uloc(HttpServletResponse response) throws IOException {
        LinkedList<String> linkedList = excelList();
        HashMap<String, String> map = dbList();
        Map<String, String> ulocMap = ulocMap();
        Map<String, String> lineMap = lineMap();
        List<UlocInfo> ulocInfoList = new ArrayList<>();
        linkedList.stream().forEach(x -> {
            String uloc = ulocMap.get(x);
            if (StrUtil.isNotBlank(uloc)) {
                Arrays.stream(uloc.split("/")).forEach(y -> {
                            UlocInfo ulocInfo = new UlocInfo();
                            String line = lineMap.get(y);
                            if (StrUtil.isNotBlank(line)) {
                                String[] split = line.split(":");
                                ulocInfo.setWorkshop_no(split[0]).setLine_no(split[1]);
                            }
                            ulocInfo.setUsername(x).setTmBasUserId(map.get(x)).setUloc_no(y).setPlant_no("AGK").setVersion("0").setGmt_create(new Date()).setCreate_by("1550350182800044033").setIs_deleted("0");
                            ulocInfoList.add(ulocInfo);
                        }
                );
            }
        });
        download(response, ulocInfoList, UlocInfo.class, "ulocInfo");
    }

    public Map<String, String> ulocMap() {
        Map<String, String> dataMap = new HashMap<>();
        dataMap.put("DZC0MON", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCBKLU", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCWF2O", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC5R7J", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCC46S", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC80EK", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC2ALD", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC1VTY", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC350D", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC2ERN", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC2VLE", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC2RUI", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCKJ0M", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("N4J5BMQ", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCK4PB", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC2ONV", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC2LHG", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("BL2XS4X", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCJP7H", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("CLU2H7C", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC2FUH", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC2STM", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCA1WX", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC2FEY", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC2LL3", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCS9KL", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCA1ZG", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCXNXF", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC2FIL", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC0AMK", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCR5D6", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCRV8N", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC7G94", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCEG2Q", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("G3TZ5RN", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("dzcw7e5", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC2S29", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC96V6", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC1GLU", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC1KUA", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("dzc0aln", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("dzcw8iz", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("dzc5xke", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("dzcd8mf", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("dzcgi8v", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("dzce2fr", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("dzcbvx3", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("dzc8mj8", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("dzcqwc8", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("dzc6ecg", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("dzc94ck", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCMU95", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCHLH5", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCB6VC", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC2BAY", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC5D0B", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC2GAI", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC0IG3", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCR3DB", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCZHSX", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCUB4G", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC0IKI", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC2KOA", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCKR2E", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC02MB", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC2LAL", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC2LIN", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCS4E2", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC04TC", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCOB8P", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCAOI6", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCOT0F", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("K2L6DWX", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCMDYD", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCNJQJ", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCO8EC", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCEK6F", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("K3GL2GY", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC3VNH", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCLMX6", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC0KA8", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC2P1Z", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZCE29Q", "CP6/CP7/WT/VC/DRV/CP8");
        dataMap.put("DZC4LF8", "M50");
        dataMap.put("dzcganb", "M50");
        dataMap.put("DZC2BDA", "M50");
        dataMap.put("DZCI377", "M50");
        dataMap.put("DZCML2N", "M50");
        dataMap.put("DZC0DYA", "M50");
        dataMap.put("DZC0KDG", "M50");
        dataMap.put("DZC1TH3", "M50");
        dataMap.put("DZC0DKI", "M50");
        dataMap.put("DZC0EG0", "M50");
        dataMap.put("DZC4BJ1", "M50");
        dataMap.put("DZC0KDS", "M50");
        return dataMap;
    }


    public static void download(HttpServletResponse response, List<?> exports, Class head, String exportFileName) throws IOException {
        response.setContentType("application/vnd.ms-excel");
        response.setCharacterEncoding("utf-8");
        String excelName = URLEncoder.encode(exportFileName + ".xlsx", "UTF-8");
        response.setHeader("Content-disposition", "attachment;filename=" + excelName);

        EasyExcel.write(response.getOutputStream(), head)
                .sheet(1, "Sheet1")
                .doWrite(exports);
    }

    private Map<String, String> lineMap() {
        Map<String, String> dataMap = new HashMap<>();
        // 填充键值对
        dataMap.put("A300", "LG01:LG01");
        dataMap.put("S50", "LG01:LG01");
        dataMap.put("M50", "LG01:LG01");
        dataMap.put("M101", "AP01:SKD1");
        dataMap.put("ZP6", "AP01:SKD1");
        dataMap.put("ZP7", "AP01:SKD1");
        dataMap.put("M100", "AP02:SKD2");
        dataMap.put("CP6", "AP02:SKD2");
        dataMap.put("CP7", "AP02:SKD2");
        dataMap.put("GEO", "AP02:SKD2");
        dataMap.put("WT", "AP02:SKD2");
        dataMap.put("VC", "AP02:SKD2");
        dataMap.put("DRV", "AP02:SKD2");
        dataMap.put("CP8", "AP02:SKD2");
        dataMap.put("Powertrain", "AP02:SKD2");
        dataMap.put("TW17", "AP02:SKD2");
        return dataMap;
    }

    private static HashMap<String, String> dbList() {
        HashMap<String, String> map = new HashMap<>();
        map.
                put("dzc5xke", "1858400167542423554");
        map.
                put("dzc8mj8", "1858400169069150210");
        map.
                put("BL2XS4X", "1858400159933956097");
        map.

                put("CLU2H7C", "1858400160554713089");
        map.

                put("DZC02MB", "1858400174509162497");
        map.

                put("DZC04TC", "1858400175654207490");
        map.

                put("DZC0AAA", "1858400195640066050");
        map.

                put("dzc0aln", "1858400166971998209");
        map.

                put("DZC0AMK", "1858400163515891713");
        map.

                put("DZC0BV0", "1858400182159572994");
        map.

                put("DZC0CSN", "1858400188509749250");
        map.

                put("DZC0DKI", "1858400185754091521");
        map.

                put("DZC0DYA", "1858400184848121857");
        map.

                put("DZC0EG0", "1858400186077052930");
        map.

                put("DZC0IG3", "1858400172323930113");
        map.

                put("DZC0IKI", "1858400173569638402");
        map.

                put("DZC0KA8", "1858400179206782977");
        map.

                put("DZC0KDG", "1858400185183666177");
        map.

                put("DZC0KDS", "1858400186702004225");
        map.

                put("DZC0KIB", "1858400183011016705");
        map.

                put("DZC0KIR", "1858400180939030530");
        map.

                put("DZC0MON", "1858400154632355842");
        map.

                put("DZC1GLU", "1858400166309298177");
        map.

                put("DZC1JTS", "1858400193278672897");
        map.

                put("DZC1KUA", "1858400166640648194");
        map.

                put("DZC1O9U", "1858400190070030337");
        map.

                put("DZC1TH3", "1858400185468878850");
        map.

                put("DZC1VTY", "1858400156863725569");
        map.

                put("DZC1ZAB", "1858400181220048897");
        map.

                put("DZC21XT", "1858400194423717890");
        map.

                put("DZC2ALD", "1858400156540764162");
        map.

                put("DZC2BAY", "1858400171338268674");
        map.

                put("DZC2BDA", "1858400183929569281");
        map.

                put("DZC2ERN", "1858400157450928130");
        map.

                put("DZC2FEY", "1858400161733312514");
        map.

                put("DZC2FIL", "1858400163188736002");
        map.

                put("DZC2FUH", "1858400160839925761");
        map.

                put("DZC2GAI", "1858400172030328834");
        map.

                put("DZC2KOA", "1858400173913571330");
        map.

                put("DZC2KUL", "1858400181878554625");
        map.

                put("DZC2KVA", "1858400193857486849");
        map.

                put("DZC2LAL", "1858400174798569474");
        map.

                put("DZC2LHG", "1858400159573245953");
        map.

                put("DZC2LIN", "1858400175083782145");
        map.

                put("DZC2LL3", "1858400162018525185");
        map.

                put("DZC2ONV", "1858400159246090242");
        map.

                put("DZC2P1Z", "1858400179487801345");
        map.

                put("DZC2RUI", "1858400158021353473");
        map.

                put("DZC2S29", "1858400165650792449");
        map.

                put("DZC2STM", "1858400161167081473");
        map.

                put("DZC2VLE", "1858400157736140802");
        map.

                put("DZC350D", "1858400157165715458");
        map.

                put("DZC3UTB", "1858400187322761218");
        map.

                put("DZC3VNH", "1858400178619580418");
        map.

                put("DZC4BJ1", "1858400186366459905");
        map.

                put("DZC4LF8", "1858400183338172417");
        map.

                put("DZC5ANP", "1858400182725804033");
        map.

                put("DZC5D0B", "1858400171698978817");
        map.

                put("DZC5R7J", "1858400155500576769");
        map.

                put("dzc6ecg", "1858400169689907201");
        map.

                put("dzc6n10", "1858400194989948929");
        map.

                put("DZC7G94", "1858400164467998722");
        map.

                put("DZC7KCL", "1858400181501067265");
        map.

                put("DZC80EK", "1858400156201025537");
        map.

                put("dzc94ck", "1858400169975119873");
        map.

                put("DZC96V6", "1858400165982142465");
        map.

                put("DZCA1WX", "1858400161452294145");
        map.

                put("DZCA1ZG", "1858400162622504962");
        map.

                put("DZCAOI6", "1858400176266575874");
        map.

                put("DZCB6VC", "1858400170935615490");
        map.

                put("DZCBJP7", "1858400189390553089");
        map.

                put("DZCBKLU", "1858400154921762818");
        map.

                put("dzcbvx3", "1858400168741994497");
        map.

                put("DZCC46S", "1858400155873869826");
        map.

                put("DZCD76N", "1858400188794961921");
        map.

                put("dzcd8mf", "1858400167831830530");
        map.

                put("DZCE29Q", "1858400179773014017");
        map.

                put("dzce2fr", "1858400168406450177");
        map.

                put("DZCEG2Q", "1858400164753211393");
        map.

                put("DZCEK6F", "1858400178049155073");
        map.

                put("dzcganb", "1858400183623385090");
        map.

                put("dzcgi8v", "1858400168117043202");
        map.

                put("DZCH422", "1858400194142699522");
        map.

                put("DZCHAUB", "1858400191860998146");
        map.

                put("DZCHLH5", "1858400170591682561");
        map.

                put("DZCI377", "1858400184214781954");
        map.

                put("DZCIBRA", "1858400190401380354");
        map.

                put("DZCIKDK", "1858400193563885570");
        map.

                put("DZCJMM9", "1858400191294767105");
        map.

                put("DZCJP7H", "1858400160219168769");
        map.

                put("DZCJXCB", "1858400192712441858");
        map.

                put("DZCK4PB", "1858400158918934530");
        map.

                put("DZCKJ0M", "1858400158302371841");
        map.

                put("DZCKLXB", "1858400186987216897");
        map.

                put("DZCKR2E", "1858400174219755522");
        map.

                put("DZCL8KE", "1858400192427229186");
        map.

                put("DZCLMX6", "1858400178917376001");
        map.

                put("DZCM280", "1858400190732730370");
        map.

                put("DZCMDYD", "1858400177113825281");
        map.

                put("DZCML2N", "1858400184499994625");
        map.

                put("DZCMU95", "1858400170260332546");
        map.

                put("DZCN15J", "1858400188224536577");
        map.

                put("DZCNJQJ", "1858400177399037953");
        map.

                put("DZCO8EC", "1858400177721999361");
        map.

                put("DZCOB8P", "1858400175939420162");
        map.

                put("DZCOT0F", "1858400176547594242");
        map.

                put("DZCOTME", "1858400194708930561");
        map.

                put("DZCPF4Z", "1858400189738680321");
        map.

                put("DZCPVH6", "1858400192993460226");
        map.

                put("DZCQ780", "1858400187943518210");
        map.

                put("dzcqwc8", "1858400169404694529");
        map.

                put("DZCR3DB", "1858400172617531394");
        map.

                put("DZCR5D6", "1858400163801104386");
        map.

                put("DZCRV8N", "1858400164124065793");
        map.

                put("DZCS4E2", "1858400175368994818");
        map.

                put("DZCS9KL", "1858400162303737857");
        map.

                put("DZCSO4Z", "1858400191579979777");
        map.

                put("DZCTRHP", "1858400191013748737");
        map.

                put("DZCU2ZS", "1858400189080174593");
        map.

                put("DZCU4CO", "1858400180364410882");
        map.

                put("DZCUB4G", "1858400173276037122");
        map.

                put("dzcv82i", "1858400195359047681");
        map.

                put("DZCVQYI", "1858400180653817857");
        map.

                put("dzcw7e5", "1858400165323636738");
        map.

                put("dzcw8iz", "1858400167257210882");
        map.

                put("DZCWF2O", "1858400155206975489");
        map.

                put("DZCWMQ7", "1858400180079198210");
        map.

                put("DZCX5P3", "1858400192146210817");
        map.

                put("DZCXNXF", "1858400162907717634");
        map.

                put("DZCYR3T", "1858400182444785666");
        map.

                put("DZCZHSX", "1858400172902744065");
        map.

                put("DZCZMBV", "1858400187658305538");
        map.

                put("G3TZ5RN", "1858400165038424066");
        map.

                put("K2L6DWX", "1858400176828612610");
        map.

                put("K3GL2GY", "1858400178334367745");
        map.

                put("N4J5BMQ", "1858400158633721858");
        return map;
    }

    private static LinkedList<String> excelList() {
        LinkedList<String> list = new LinkedList<>();
        list.add("dzc5xke");
        list.add("dzc8mj8");
        list.add("BL2XS4X");
        list.add("CLU2H7C");
        list.add("DZC02MB");
        list.add("DZC04TC");
        list.add("DZC0AAA");
        list.add("dzc0aln");
        list.add("DZC0AMK");
        list.add("DZC0BV0");
        list.add("DZC0CSN");
        list.add("DZC0DKI");
        list.add("DZC0DYA");
        list.add("DZC0EG0");
        list.add("DZC0IG3");
        list.add("DZC0IKI");
        list.add("DZC0KA8");
        list.add("DZC0KDG");
        list.add("DZC0KDS");
        list.add("DZC0KIB");
        list.add("DZC0KIR");
        list.add("DZC0MON");
        list.add("DZC1GLU");
        list.add("DZC1JTS");
        list.add("DZC1KUA");
        list.add("DZC1O9U");
        list.add("DZC1TH3");
        list.add("DZC1VTY");
        list.add("DZC1ZAB");
        list.add("DZC21XT");
        list.add("DZC2ALD");
        list.add("DZC2BAY");
        list.add("DZC2BDA");
        list.add("DZC2ERN");
        list.add("DZC2FEY");
        list.add("DZC2FIL");
        list.add("DZC2FUH");
        list.add("DZC2GAI");
        list.add("DZC2KOA");
        list.add("DZC2KUL");
        list.add("DZC2KVA");
        list.add("DZC2LAL");
        list.add("DZC2LHG");
        list.add("DZC2LIN");
        list.add("DZC2LL3");
        list.add("DZC2ONV");
        list.add("DZC2P1Z");
        list.add("DZC2RUI");
        list.add("DZC2S29");
        list.add("DZC2STM");
        list.add("DZC2VLE");
        list.add("DZC350D");
        list.add("DZC3UTB");
        list.add("DZC3VNH");
        list.add("DZC4BJ1");
        list.add("DZC4LF8");
        list.add("DZC5ANP");
        list.add("DZC5D0B");
        list.add("DZC5R7J");
        list.add("dzc6ecg");
        list.add("dzc6n10");
        list.add("DZC7G94");
        list.add("DZC7KCL");
        list.add("DZC80EK");
        list.add("dzc94ck");
        list.add("DZC96V6");
        list.add("DZCA1WX");
        list.add("DZCA1ZG");
        list.add("DZCAOI6");
        list.add("DZCB6VC");
        list.add("DZCBJP7");
        list.add("DZCBKLU");
        list.add("dzcbvx3");
        list.add("DZCC46S");
        list.add("DZCD76N");
        list.add("dzcd8mf");
        list.add("DZCE29Q");
        list.add("dzce2fr");
        list.add("DZCEG2Q");
        list.add("DZCEK6F");
        list.add("dzcganb");
        list.add("dzcgi8v");
        list.add("DZCH422");
        list.add("DZCHAUB");
        list.add("DZCHLH5");
        list.add("DZCI377");
        list.add("DZCIBRA");
        list.add("DZCIKDK");
        list.add("DZCJMM9");
        list.add("DZCJP7H");
        list.add("DZCJXCB");
        list.add("DZCK4PB");
        list.add("DZCKJ0M");
        list.add("DZCKLXB");
        list.add("DZCKR2E");
        list.add("DZCL8KE");
        list.add("DZCLMX6");
        list.add("DZCM280");
        list.add("DZCMDYD");
        list.add("DZCML2N");
        list.add("DZCMU95");
        list.add("DZCN15J");
        list.add("DZCNJQJ");
        list.add("DZCO8EC");
        list.add("DZCOB8P");
        list.add("DZCOT0F");
        list.add("DZCOTME");
        list.add("DZCPF4Z");
        list.add("DZCPVH6");
        list.add("DZCQ780");
        list.add("dzcqwc8");
        list.add("DZCR3DB");
        list.add("DZCR5D6");
        list.add("DZCRV8N");
        list.add("DZCS4E2");
        list.add("DZCS9KL");
        list.add("DZCSO4Z");
        list.add("DZCTRHP");
        list.add("DZCU2ZS");
        list.add("DZCU4CO");
        list.add("DZCUB4G");
        list.add("dzcv82i");
        list.add("DZCVQYI");
        list.add("dzcw7e5");
        list.add("dzcw8iz");
        list.add("DZCWF2O");
        list.add("DZCWMQ7");
        list.add("DZCX5P3");
        list.add("DZCXNXF");
        list.add("DZCYR3T");
        list.add("DZCZHSX");
        list.add("DZCZMBV");
        list.add("G3TZ5RN");
        list.add("K2L6DWX");
        list.add("K3GL2GY");
        list.add("N4J5BMQ");
        return list;
    }


    public static void main(String[] args) {
        List<String> colorCodes = Arrays.asList("BW", "CL", "GV", "KH", "NL", "VS", "WA", "ZE", "ZF", "GX", "SJ", "VQ");
        List<List<String>> list = Arrays.asList(
                Arrays.asList("T6470BD**FF0060", "1", "1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"),
                Arrays.asList("T6470BD**FF0066", "1", "1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"),
                Arrays.asList("T6470BF**HK0038", "1", "1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"),
                Arrays.asList("T6470BF**HK0042", "1", "1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"),
                Arrays.asList("T71618K**FF0167", "1", "1", "1", "1", "1", "0", "1", "0", "0", "0", "0", "0"),
                Arrays.asList("T71618K**FF0164", "1", "1", "1", "1", "1", "0", "1", "1", "1", "0", "0", "0"),
                Arrays.asList("T71618K**FF0165", "1", "1", "1", "1", "1", "0", "1", "1", "1", "0", "0", "0"),
                Arrays.asList("T7161EL**FG0020", "1", "1", "1", "1", "1", "0", "1", "0", "0", "0", "0", "0"),
                Arrays.asList("T7161EL**FG0018", "1", "1", "1", "1", "1", "0", "1", "1", "1", "0", "0", "0"),
                Arrays.asList("T7161EL**FG0019", "1", "1", "1", "1", "1", "0", "1", "1", "1", "0", "0", "0"),
                Arrays.asList("T71526W**HC0033", "1", "1", "1", "1", "1", "1", "0", "0", "0", "0", "0", "0"),
                Arrays.asList("T71536X**GW0066", "1", "1", "1", "1", "1", "1", "0", "0", "0", "0", "0", "0"),
                Arrays.asList("T71536X**GW0070", "1", "1", "1", "1", "1", "1", "0", "0", "0", "0", "0", "0"),
                Arrays.asList("T71546Y**FR0077", "1", "1", "1", "1", "1", "1", "0", "0", "0", "0", "0", "0"),
                Arrays.asList("T71546Y**FR0073", "1", "1", "1", "1", "1", "1", "0", "0", "0", "0", "0", "0"));
        ArrayList<List<String>> dataList = new ArrayList<>();
        for (List<String> strList : list) {
            ArrayList<String> data = new ArrayList<>();
            String material = strList.get(0);
            for (int i = 1; i < strList.size(); i++) {
                if (strList.get(i).equals("1")) {
                    data.add(StrUtil.replace(material, "**", colorCodes.get(i - 1)));
                }
            }
            dataList.add(data);
        }

        System.out.println("data = " + dataList.size());
        System.out.println("data = " + JSONUtil.toJsonPrettyStr(dataList));
    }
}
